package com.example.mobiletest.model

data class Booking(
    val shipReference: String,
    val shipToken: String,
    val canIssueTicketChecking: Boolean,
    val expiryTime: String,
    val duration: Int,
    val segments: List<Segment>,
    val cacheTime: Long = System.currentTimeMillis() // 添加缓存时间戳用于时效性检查
) {
    // 检查数据是否过期（5分钟过期时间）
    fun isExpired(): Boolean {
        return System.currentTimeMillis() - cacheTime > 5 * 60 * 1000
    }
    
    // 根据expiryTime检查预订是否过期
    fun isBookingExpired(): Boolean {
        return try {
            val expiryTimeMillis = expiryTime.toLong() * 1000
            System.currentTimeMillis() > expiryTimeMillis
        } catch (e: NumberFormatException) {
            false
        }
    }
}